package com.aaa.rabbitmq.eight;

import com.aaa.rabbitmq.one.util.RabbitMQUtil;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;

import java.nio.charset.StandardCharsets;

/**
 * 死信队列 生产者
 * 只需要发送给普通交换机信息
 */
public class Producer {
    //普通交换机的名称
    public static final String NORMAL_EXCHANGE_NAME = "normal_exchange";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtil.getChannel();
        //发送延迟消息/死信消息   设置ttl  time to live 存活时间  单位是毫秒
//        AMQP.BasicProperties properties=
//                new AMQP.BasicProperties()
//                        .builder().expiration("10000").build();

        for (int i = 1; i <11 ; i++) {
            String message = "info"+i;
            channel.basicPublish(NORMAL_EXCHANGE_NAME,"zhangsan",null,message.getBytes(StandardCharsets.UTF_8));
        }



    }

}
